﻿using Wizard.UI;

namespace AppScan
{
    public partial class ScanOptionsPage : InternalWizardPage
    {
        private readonly CreateUserContext _context;

        public ScanOptionsPage(CreateUserContext context)
        {
            _context = context;
            InitializeComponent();
        }

        private void SummaryPage_WizardBack(object sender, Wizard.UI.WizardPageEventArgs e)
        {
            //if (_context.ShowAdvancedPasswordOptions)
            //    e.NewPage = "AdvancedPasswordOptionsPage";
            //else
                e.NewPage = "PasswordPage";
        }

        private void AdvancedPasswordOptionsPage_WizardNext(object sender, WizardPageEventArgs e)
        {
            _context.prefix= textBox1.Text;
            _context.installedpackages_scan = installedpackages_checkBox.Checked;
            _context.qfe_scan = quickfixengin_checkBox.Checked;
            _context.misc_scan = misc_scan_checkBox.Checked;
            _context.reg = reg_uninstall.Checked;
            e.NewPage = "SummaryPage";
        }

        private void userMustChangePasswordCheckBox_CheckedChanged(object sender, System.EventArgs e)
        {
            EnableControls();
        }

        private void EnableControls()
        {
            SetWizardButtons(WizardButtons.Back);
            
            if (installedpackages_checkBox.Checked)
                SetWizardButtons(WizardButtons.Back | WizardButtons.Next);
            if (quickfixengin_checkBox.Checked)
                SetWizardButtons(WizardButtons.Back | WizardButtons.Next);
            if (misc_scan_checkBox.Checked)
                SetWizardButtons(WizardButtons.Back | WizardButtons.Next);
        }

        private void quickfixengin_checkBox_CheckedChanged(object sender, System.EventArgs e)
        {
            EnableControls();
        }

        private void misc_scan_checkBox_CheckedChanged(object sender, System.EventArgs e)
        {
            EnableControls();
        }

        private void textBox1_TextChanged(object sender, System.EventArgs e)
        {
            EnableControls();
        }

    }
}
